/**
*    Copyright (C) 2008  Chase Kernan 
*    chase.kernan@gmail.com
*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

package com.chasekernan.hxnova.server.functions;

import com.chasekernan.hxnova.core.dataholders.Global;
import com.chasekernan.hxnova.core.stars.Star;

/**
    Refuels ships that are at a starbase.
    TODO: Allow for starbase to not be able to refuel ships (ie docks)
*/
class Refueling {
    
    public static function run() {
        for (star in Global.stars) {
			if (star.starbase == null) continue;
			
            switch (star.starbase) {
                
                case Design(d):
					if (star.orbitingFleets == null) continue;
					
                    for (fleet in star.orbitingFleets) {
                        if (fleet.owner.id == star.owner.id || 
								star.owner.relations.isFriendOf(fleet.owner)) {
							fleet.fuel = fleet.getFuelCapacity();
						}
                    }
                    
                default: //do nothing
            }
        }
    }
}